

 
						***************************
						** Analysing the results **
						***************************	
						
						*********************** 
						** VARIABLE: 65 y1919_1994 *
						***********************
	
	clear
	version 15.1
	set seed 1234
	cd  "/Users/rich/Dropbox/research/Rich & Ferran/EBA turnout/data/completed data/completed AWS data files (raw)/VAPVT/"
		
	use eba_vapvt_65_aws.dta
		
		** dropping unnecessary variables **
		
			drop if _id==.
			drop title marginsok vce depvar cmd properties predict model ///
				estat_cmd vcetype clustvar 
			
		** 1.1. regressions calculated
	
			codebook _id
		
		** 1.2. dropping models if vif>7
 
			drop if vif1>7
			
			codebook _id
		
		** 1.3. Mean of Coef, SE, min, max    **
		 
			sum coef if var=="y1919_1994"
		
		** 1.4.  %(significant != 0)  **
 
			count if var=="y1919_1994" &   pval<=.05 & pval~=.
	 	
		** 1.5. %(beta < 0)  
		 
			count if var=="y1919_1994" & coef<0 & coef~=.

		** 1.5. %(beta > 0)  
		 
			count if var=="y1919_1994" & coef>0 & coef~=.
				
		** 1.6.  %(signif & beta <= 0)  
				
			count if var=="y1919_1994" &  	pval<=.05 &	coef<=0 
		
		** 1.7.  %(signif & beta > 0)  
				
			count if var=="y1919_1994" &  	pval<=.05 &	coef>0 
			
		** Hegre and Sambanis weights calculation **		
		
			** generating weights 
			egen llsum_all= sum(ll)
			gen w_all=ll/llsum_all
			
			* beta *
			gen beta_w=coef*w_all if var=="y1919_1994"
			egen beta_mean=sum(beta_w)		
			codebook beta_mean
			
			* sd *
			gen sd_w=stderr*w_all if var=="y1919_1994"
			egen sd_mean=sum(sd_w)
			codebook sd_mean
			
			* Tstat  *
			gen t=beta_mean/sd_mean
			codebook  t
			
			** Pvalue  (ttail(DF, T)
			display ttail(   38191   ,1.5181412) 
			                     
 
		** Sala-i-Martin's Extreme Bounds Analysis (EBA):
		
			** - Normal model (N): beta coefficients assumed to be distributed normally across models
			** - Generic model (G): no assumption about the distribution of beta coefficients across models
				 
			  
 		cumul coef if var=="y1919_1994", gen(cdf) equal
 		cumul beta_mean if var=="y1919_1994", gen(cdf_w) equal
				
		sort coef
		browse coef cdf cdf_w if cdf~=.	
 
		saveold vt_65_aws.dta, version(13) replace 
		
							 
								************** 
								*** GRAPHS *** 
								**************
								
	** histograms of coefficients **
	
		** adding normal distribution to visualise whether the normal assumption 
		** is born out by the data 

		
		global graph_options ", freq  xline(0, lcolor(red)) ytitle("") xtitle("") normal gap(25) ylabel(, angle(0) labsize(small))"
		
 
		** In all models ***
		hist coef if var=="vt_lag" $graph_options title("Lagged DV") saving(h1, replace)
		hist coef if var=="comp" $graph_options title("Compulsory voting") saving(h2, replace)
		hist coef if var=="gni_ln_sl" $graph_options title("GNI") saving(h3, replace)
		hist coef if var=="pop_ln_sl" $graph_options title("Population") saving(h4, replace)		
		hist coef if var=="pr" $graph_options title("Proportional representation") saving(h5, replace)
		
		** Rotating variables
		hist coef if var=="africa" $graph_options title("Africa") saving(h6, replace)
		hist coef if var=="asia" $graph_options title("Asia") saving(h7, replace)		
		
		hist coef if var=="ban" $graph_options title("Ban") saving(h8, replace)
		hist coef if var=="boycott" $graph_options title("Boycott") saving(h9, replace)	
		
		hist coef if var=="competitive_s" $graph_options title("Competitive elections") saving(h10, replace)
		hist coef if var=="concurrentsamedate" $graph_options title("Concurrent election") saving(h11, replace)

		hist coef if var=="dist_mag_s" $graph_options title("District Magnitude") saving(h12, replace)
		
		hist coef if var=="econ_global_sl" $graph_options title("Economic globalization") saving(h13, replace)	
		hist coef if var=="eeurope" $graph_options title("Eastern Europe") saving(h14, replace)		
		hist coef if var=="election_2" $graph_options title("2nd election") saving(h15, replace)
		hist coef if var=="election_3" $graph_options title("3rd election") saving(h16, replace)
		hist coef if var=="election_4" $graph_options title("4th election") saving(h17, replace)
		hist coef if var=="election_3_4" $graph_options title("3rd & 4th election") saving(h18, replace)
		hist coef if var=="election_5_6" $graph_options title("5th & 6th election") saving(h19, replace)
		hist coef if var=="election_7_8" $graph_options title("7th & 8th election") saving(h20, replace)		
		hist coef if var=="enpp_s" $graph_options title("Effective # political parties") saving(h21, replace)
		hist coef if var=="enpp_sq_s" $graph_options title("ENPP ^2") saving(h22, replace)
		hist coef if var=="exec_response" $graph_options title("Executive response") saving(h23, replace)

  		hist coef if var=="federalism" $graph_options title("Federalism") saving(h24, replace)
		hist coef if var=="fract_ethnic_s" $graph_options title("Ethnic fractionalization") saving(h25, replace)
		hist coef if var=="fract_lang_s" $graph_options title("Language fractionalization") saving(h26, replace)
		hist coef if var=="fract_rel_s" $graph_options title("Religious fractionalization") saving(h27, replace)

 		hist coef if var=="gini_sl" $graph_options title("GINI") saving(h28, replace)		
		hist coef if var=="gni_pc_growth_sl" $graph_options title("GNI pc growth") saving(h29, replace)
		
		hist coef if var=="harassment" $graph_options title("Harassment") saving(h30, replace)		
		hist coef if var=="hdi_index_s" $graph_options title("HDI Index") saving(h31, replace)

		hist coef if var=="inflation_ln_sl" $graph_options title("Inflation") saving(h32, replace)		
		hist coef if var=="islamic_majority" $graph_options title("Islamic majority") saving(h33, replace)

		hist coef if var=="latin_america" $graph_options title("Latin America") saving(h34, replace)	
		hist coef if var=="leg_size_ln_s" $graph_options title("Legislature size") saving(h35, replace)		
		hist coef if var=="life_exp_sl" $graph_options title("Life expectancy") saving(h36, replace)
 
		hist coef if var=="maj_status_s" $graph_options title("Majority status") saving(h37, replace)	 
		hist coef if var=="majoritarian" $graph_options title("Majoritarian system") saving(h38, replace)
		hist coef if var=="mixed" $graph_options title("Mixed system") saving(h39, replace)			

		hist coef if var=="norway" $graph_options title("Norway") saving(h40, replace)		
		hist coef if var=="num_elections_ln_s" $graph_options title("Number of elections") saving(h41, replace)
		hist coef if var=="nz" $graph_options title("New Zealand") saving(h42, replace)

		hist coef if var=="oceania" $graph_options title("Oceania") saving(h43, replace)		
		hist coef if var=="oecd" $graph_options title("OECD") saving(h44, replace)		

		hist coef if var=="party_frac_s" $graph_options title("Party fractionalization") saving(h45, replace)		
 		hist coef if var=="plurality" $graph_options title("Plurality") saving(h46, replace)	
 		hist coef if var=="polity2_sl" $graph_options title("Polity") saving(h47, replace)	
		hist coef if var=="pop_density_ln_sl" $graph_options title("Population density") saving(h48, replace)			
		hist coef if var=="prev_el_time_s" $graph_options title("Previous election time") saving(h49, replace)
 
		hist coef if var=="qual_democ" $graph_options title("Quality of democracy") saving(h50, replace)

		hist coef if var=="radios_pc_ln_sl" $graph_options title("Radios pc") saving(h51, replace)		
		
		hist coef if var=="samerica" $graph_options title("South America") saving(h52, replace)				
 		hist coef if var=="share30to69ofVAP" $graph_options title("30-69 share of VAP") saving(h53, replace)		
		hist coef if var=="subnat_rev_sl" $graph_options title("Subnational revenue") saving(h54, replace)
		hist coef if var=="subnat_exp_sl" $graph_options title("Subnational expenditures") saving(h55, replace)
		hist coef if var=="sufferage_s" $graph_options title("Sufferage") saving(h56, replace)	
		hist coef if var=="suffreg" $graph_options title("Automatic registration") saving(h57, replace)	
		hist coef if var=="sweden" $graph_options title("Sweden") saving(h58, replace)		
		hist coef if var=="swiss" $graph_options title("Switzerland") saving(h59, replace)
 	
		hist coef if var=="time_trend_s" $graph_options title("Time trend") saving(h60, replace)

		hist coef if var=="unemployment_sl" $graph_options title("Unemployment") saving(h61, replace)
		hist coef if var=="unicameral" $graph_options title("Unicameralism") saving(h62, replace)		
		hist coef if var=="union_density" $graph_options title("Union density") saving(h63, replace)		
		hist coef if var=="unionisation" $graph_options title("Unionisation") saving(h64, replace)		
		hist coef if var=="urban_pop_pct_sl" $graph_options title("Urban population (%)") saving(h65, replace)
		hist coef if var=="usa" $graph_options title("USA") saving(h66, replace)
	
		hist coef if var=="violence" $graph_options title("Violence during election") saving(h67, replace)
		hist coef if var=="votingage" $graph_options title("Voting age") saving(h68, replace)

		hist coef if var=="west" $graph_options title("West") saving(h69, replace)
		
		hist coef if var=="y1919_1994" $graph_options title("1919-1994") saving(h70, replace)
 
		** combining coefficient graphs **
 
		graph combine 	h1.gph h2.gph h3.gph h4.gph h5.gph 					///
						h6.gph h7.gph h8.gph h9.gph h10.gph 				///
						h11.gph h12.gph h13.gph h14.gph h15.gph 			///
						h16.gph h17.gph h18.gph h19.gph h20.gph 			///		
						h21.gph h22.gph h23.gph h24.gph h25.gph 			///
						h26.gph h27.gph h28.gph h29.gph h30.gph 			///	
						h31.gph h32.gph h33.gph h34.gph h35.gph 			///
						h36.gph h37.gph h38.gph h39.gph h40.gph 			///							
						h41.gph h42.gph h43.gph h44.gph h45.gph 			///
						h46.gph h47.gph h48.gph h49.gph h50.gph 			///							
						h51.gph h52.gph h53.gph h54.gph h55.gph 			///
						h56.gph h57.gph h58.gph h59.gph h60.gph 			///	
						h61.gph h62.gph h63.gph h64.gph h65.gph 			///
						h66.gph h67.gph h68.gph h69.gph h70.gph , 			///
						title("65 y1919_1994") saving(65_y1919_1994.gph, replace)
	 
		erase h1.gph
		erase h2.gph
		erase h3.gph
		erase h4.gph
		erase h5.gph
		erase h6.gph
		erase h7.gph
		erase h8.gph
		erase h9.gph
		erase h10.gph
 
		erase h11.gph
		erase h12.gph
		erase h13.gph
		erase h14.gph
		erase h15.gph
		erase h16.gph
		erase h17.gph
		erase h18.gph
		erase h19.gph
		erase h20.gph
 
		erase h21.gph
		erase h22.gph
		erase h23.gph
		erase h24.gph
		erase h25.gph
		erase h26.gph
		erase h27.gph
		erase h28.gph
		erase h29.gph
		erase h30.gph	
	
		erase h31.gph
		erase h32.gph
		erase h33.gph
		erase h34.gph
		erase h35.gph
		erase h36.gph
		erase h37.gph
		erase h38.gph
		erase h39.gph
		erase h40.gph	
	
		erase h41.gph
		erase h42.gph
		erase h43.gph
		erase h44.gph
		erase h45.gph
		erase h46.gph
		erase h47.gph
		erase h48.gph
		erase h49.gph
		erase h50.gph	
	
		erase h51.gph
		erase h52.gph
		erase h53.gph
		erase h54.gph
		erase h55.gph
		erase h56.gph
		erase h57.gph
		erase h58.gph
		erase h59.gph
		erase h60.gph	
	
		erase h61.gph
		erase h62.gph	 
		erase h63.gph
		erase h64.gph
		erase h65.gph
		erase h66.gph
		erase h67.gph
		erase h68.gph
		erase h69.gph	 
		erase h70.gph	
